<div style="float:right; width:400px; position:relative">
        	<?php
				$i=0;
				//$income2[0]=0;
				//$outcome2[0]=0;
				$benifit2[0]=0;
				//echo $oldestYear;die();
				//for current year
				if($numYear2>=1)
					if($results25->num_rows()>0){
						foreach($results25->result() as $rows){
							//$income2[$i]=$rows->credit==''?0:$rows->credit;
							//$outcome2[$i]=$rows->outcome==''?0:$rows->outcome;
							$benifit2[$i]=$rows->credit==''?0:$rows->credit;
/*							echo '<div style="border:1px solid #ddd; margin:5px;padding: 5px;position: relative; width:150px; float:left;"><p><b>'.date('Y').'</b><br />';
							//echo 'Income: <b>'.$income[$i].'$</b><br />';
							//echo 'Payment: <b>'.$outcome[$i].'$</b><br />';
							echo 'Credit: <b>'.$rows->credit.'$</b><br />';
							echo '</p></div>';
*/							$i++;
						}
					}else{
						echo "No";	
					}
				//for current year - 1
				if($numYear2>=2)
				if($results24->num_rows()>0){
					foreach($results24->result() as $rows){
						//$income2[$i]=$rows->income;
						//$outcome2[$i]=$rows->outcome;
						$benifit2[$i]=$rows->credit==''?0:$rows->credit;
/*						echo '<div style="border:1px solid #ddd; margin:5px;padding: 5px;position: relative; width:150px; float:left;"><p><b>'.(date('Y')-1) .'</b><br />';
						//echo 'Income: <b>'.$rows->income.'$</b><br />';
						//echo 'Payment: <b>'.$rows->outcome.'$</b><br />';
						echo 'Credit: <b>'.$rows->credit.'$</b><br />';
						echo '</p></div>';
*/						$i++;
					}
				}else{
					echo "No";	
				}
				//for current year - 2
				if($numYear2>=3)
				if($results23->num_rows()>0){
					foreach($results23->result() as $rows){
						//$income2[$i]=$rows->income;
						//$outcome2[$i]=$rows->outcome;
						$benifit2[$i]=$rows->credit==''?0:$rows->credit;
/*						echo '<div style="border:1px solid #ddd; margin:5px;padding: 5px;position: relative; width:150px; float:left;"><p><b>'.(date('Y')-2) .'</b><br />';
						//echo 'Income: <b>'.$rows->income.'$</b><br />';
						//echo 'Payment: <b>'.$rows->outcome.'$</b><br />';
						echo 'Credit: <b>'.$rows->credit.'$</b><br />';
						echo '</p></div>';
*/						$i++;
					}
				}else{
					echo "No";	
				}
				//for current year - 3
				if($numYear2>=4)
				if($results22->num_rows()>0){
					foreach($results22->result() as $rows){
						//$income2[$i]=$rows->income;
						//$outcome2[$i]=$rows->outcome;
						$benifit2[$i]=$rows->credit==''?0:$rows->credit;
/*						echo '<div style="border:1px solid #ddd; margin:5px;padding: 5px;position: relative; width:150px; float:left;"><p><b>'.(date('Y')-3) .'</b><br />';
						//echo 'Income: <b>'.$rows->income.'$</b><br />';
						//echo 'Payment: <b>'.$rows->outcome.'$</b><br />';
						echo 'Credit: <b>'.$rows->credit.'$</b><br />';
						echo '</p></div>';
*/						$i++;
					}
				}else{
					echo "No";	
				}/**/
				//for current year - 4
				if($numYear2>=5)
				if($results21->num_rows()>0){
					foreach($results21->result() as $rows){
						//$income2[$i]=$rows->income;
						//$outcome2[$i]=$rows->outcome;
						$benifit2[$i]=$rows->credit==''?0:$rows->credit;
/*						echo '<div style="border:1px solid #ddd; margin:5px;padding: 5px;position: relative; width:150px; float:left;"><p><b>'.(date('Y')-4) .'</b><br />';
						//echo 'Income: <b>'.$rows->income.'$</b><br />';
						//echo 'Payment: <b>'.$rows->outcome.'$</b><br />';
						echo 'Credit: <b>'.$rows->credit.'$</b><br />';
						echo '</p></div>';
*/						$i++;
					}
				}else{
					echo "No";	
				}
			?>
        </div>
    
<script type="text/javascript">
$(function () {
			//array_reverse($array);
    //var income2 = [];
    //var outcome2 = [];
    var benifit2 = [];
	<?php /*?><?php
		$i=0;
		foreach($income2 as $row){
	?>
			income2.push([<?php echo date('Y')-$i;?>,<?php echo $row ?>]);
	<?php
		$i++;
		}
	if($i<5){
	?>
	
	income2.push([<?php echo date('Y')-$i;?>,0]);
	<?php
	}
		$i=0;
		foreach($outcome2 as $row){
	?>
			outcome2.push([<?php echo date('Y')-$i;?>,<?php echo $row ?>]);
	<?php
		$i++;
		}
	if($i<5){
	?>
		outcome2.push([<?php echo date('Y')-$i;?>,0]);

	<?php
	}<?php */?>
	<?php
		$i=0;
		foreach($benifit2 as $row){
	?>
			benifit2.push([<?php echo date('Y')-$i;?>,<?php echo $row ?>]);
	<?php
		$i++;
		}
	if($i<5){
	?>
	benifit2.push([<?php echo date('Y')-$i;?>,0]);
	<?php
	}
	?>
	$.plot($("#productYearly"), [
       /* {
			label: "Income",
            data: income,
            lines: { show: true },
			points: {show: true}
			
        },
		{
			label: "Payment",
            data: outcome,
            lines: { show: true },
			points: {show: true}
        },*/
		{
			label: "Credit",
            data: benifit2,
            lines: { show: true },
			points: {show: true}
        }
    ],
	{
		grid: { hoverable: true, clickable: true },
		xaxis: {
			ticks: [
				<?php  echo '['.(date('Y')-4) .', "'.(date('Y')-4) .'"]';?>
				<?php  echo ',['.(date('Y')-3) .', "'.(date('Y')-3) .'"]';?>
				<?php  echo ',['.(date('Y')-2) .', "'.(date('Y')-2) .'"]';?>
				<?php  echo ',['.(date('Y')-1) .', "'.(date('Y')-1) .'"]';?>
				<?php  echo ',['.date('Y') .', "'.date('Y') .'"]';?>
			]
		}
	}
	);
	function showTooltip(x, y, contents) {
        $('<div id="tooltip">' + contents + '</div>').css( {
            position: 'absolute',
            display: 'none',
            top: y + 5,
            left: x + 5,
            border: '1px solid #fdd',
            padding: '2px',
            'background-color': '#fee',
            opacity: 0.80
        }).appendTo("body").fadeIn(200);
    }
	var previousPoint = null;
    $("#productYearly").bind("plothover", function (event, pos, item) {
        $("#x").text(pos.x.toFixed(2));
        $("#y").text(pos.y.toFixed(2));
            if (item) {
                if (previousPoint != item.dataIndex) {
                    previousPoint = item.dataIndex;
                    
                    $("#tooltip").remove();
                    var x = item.datapoint[0].toFixed(0),
                        y = item.datapoint[1].toFixed(2);
                    
                    showTooltip(item.pageX, item.pageY,
                                item.series.label + " of " + x + " = " +"$"+ y);
                }
            }
            else {
                $("#tooltip").remove();
                previousPoint = null;            
            }       
    });
});
</script>